package handlers

import (
	"image"
)

type WriteShape struct {
	X      int
	Y      int
	Color  string
	Width  int
	Height int
}

func (w *WriteShape) Handler(img *image.RGBA) (*image.RGBA, error) {
	if w.Color == "" {
		return img, nil
	}
	endWidth, endHeight := w.X+w.Width, w.Y+w.Height
	color := RGBAColor(w.Color)

	for x := w.X; x <= endWidth; x++ {
		for y := w.Y; y <= endHeight; y++ {
			img.Set(x, y, color)
		}
	}

	return img, nil
}
